﻿using DingTalk.Corp;
using DingTalk.Corp.Models;
using Microsoft.Extensions.Configuration;

namespace DingTalk.Corp.Configurations
{
    /// <summary>
    /// 
    /// </summary>
    public class DingTalkAgentSetting
    {
        /// <summary>
        /// 
        /// </summary>
        const string AUTH_SCOPE = "openid";
        /// <summary>
        /// 
        /// </summary>
        [ConfigurationKeyName("name")]
        public string Name
        {
            get;
            set;
        }
        /// <summary>
        /// 
        /// </summary>
        [ConfigurationKeyName("agentId")]
        public string AgentID
        {
            get;
            set;
        }
        /// <summary>
        /// 
        /// </summary>
        [ConfigurationKeyName("appKey")]
        public string AppKey
        {
            get;
            set;
        }
        /// <summary>
        /// 
        /// </summary>
        [ConfigurationKeyName("appSecret")]
        public string AppSecret
        {
            get;
            set;
        }
        /// <summary>
        /// 
        /// </summary>
        [ConfigurationKeyName("authScope")]
        public string AuthScope
        {
            get;
            set;
        } = AUTH_SCOPE;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="setting"></param>
        public static implicit operator DingTalkAgent(DingTalkAgentSetting setting)
        {
            return new ()
            {
                Name = setting.Name,
                AgentID = setting.AgentID,
                AppKey = setting.AppKey,
                AppSecret = setting.AppSecret,
                AuthScope = setting.AuthScope
            };
        }
    }
}
